home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_bas
/
mices
/
popmouse.sub
< prev
Wrap
Text File
|
1988-04-16
|
4KB
|
167 lines
SUB POPMOUSE(HEADER$,CHOICES%,SET%,ITEMS$(2),FRAME%,FORE%,BACK%,HFORE%,HBACK%,QUADRANT$,SHADOW%,CHOICE%) STATIC
DEFINT A-Z
DIM SCRN(2000)
' Determine width of window from length of items
WINDLEN=LEN(HEADER$)
FOR J = 1 TO CHOICES
IF LEN(ITEMS$(SET,J)) > WINDLEN THEN WINDLEN=LEN(ITEMS$(SET,J))
NEXT J
' If quadrant is in row:col format, extract row and column
IF INSTR(QUADRANT$,":") <> 0 THEN GOSUB Getord: GOTO Go1
' Determine position based on quadrant parameter and size of menu
QUADRANT=VAL(QUADRANT$)
IF QUADRANT > 4 OR QUADRANT < 0 THEN QUADRANT=0
IF QUADRANT = 0 THEN CROW=12: CCOL=40 ELSE ON QUADRANT GOSUB Quad1,Quad2,Quad3,Quad4
ULR=CROW-((CHOICES+2)/2-.5)
ULC=CCOL-((WINDLEN/2)-.5)
LRR=ULR+CHOICES+1
LRC=ULC+WINDLEN-1
Go1: 'Create window for menu
WHERE=VARPTR(SCRN(0))
CALL SCRSAVE(WHERE)
CALL MAKEWINDOW(ULC,ULR,LRC,LRR,LABEL$,FRAME,0,FORE,BACK,0)
' Place header in window
TEMPHDR$=SPACE$(WINDLEN)
IF LEN(HEADER$) <> WINDLEN THEN GOSUB Puthdr
CALL CALCATTR(HFORE,HBACK,ATTR)
ROW=ULR: COL=ULC
CALL XQPRINTD(HEADER$,ROW,COL,ATTR,0)
CALL CALCATTR(FORE,BACK,ATTR)
ROW=ULR+1: COL=ULC
DAT$=STRING$(WINDLEN,205)
CALL XQPRINTD(DAT$,ROW,COL,ATTR,0)
GOSUB Make.Menu
' Set current choice to menu item #1 and enter loop
CLICK=0: CHOICE=1: CALL CLRKBD: GOSUB Turn.On: CALL MMCHECK(MOUSE)
IF MOUSE <> 0 THEN
MOUSE=-1: LFTCOL=8*COL-8: TOPROW=8*ROW-8
RGTCOL=8*LRC-8: BOTROW=8*LRR-8
CALL MMSETRANGE(LFTCOL,TOPROW,RGTCOL,BOTROW)
END IF
GOSUB Turn.Off: ' Update position of selection marker
Lope:
IF MOUSE THEN GOSUB LopeX: IF CLICK GOTO Done
GOSUB Press ' Get keypress
IF KP$ = CHR$(13) OR KP$ = CHR$(27) GOTO Done
GOTO Lope
' Check for left or right mouse button clicked
Lopex:
CALL MMBUTTON(LFT,RGT)
IF RGT <> 0 THEN CHOICE=0: CLICK=-1: RETURN
CALL MMGETLOC(MOUSECOL,MOUSEROW)
IF LFT <> 0 THEN CHOICE=MOUSEROW\8-ULR: CLICK=-1: RETURN
IF CHOICE = MOUSEROW\8-ULR THEN RETURN
OLD=CHOICE: CHOICE=MOUSEROW\8-ULR: GOSUB Turn.Off: RETURN
' Check for keypress and sound error if not up arrow, down arrow, or return
Press:
KP$=INKEY$
IF KP$ = "" THEN RETURN
IF KP$ = CHR$(13) THEN RETURN
IF KP$ = CHR$(27) THEN CHOICE=0: RETURN
' Sound error if not up arrow, down arrow, home, end, page up, page down, or return
IF LEN(KP$) = 1 THEN SOUND 1000,1: SOUND 1500,2: SOUND 500,1: RETURN
' Process down arrow keypress
IF ASC(RIGHT$(KP$,1)) = 80 THEN
OLD=CHOICE: CHOICE=CHOICE+1
IF CHOICE > CHOICES THEN CHOICE=1
GOSUB Turn.Off: RETURN
END IF
' Process up arrow keypress
IF ASC(RIGHT$(KP$,1)) = 72 THEN
OLD=CHOICE: CHOICE=CHOICE-1
IF CHOICE < 1 THEN CHOICE=CHOICES
GOSUB Turn.Off: RETURN
END IF
' Process error
SOUND 1000,1: SOUND 1500,2: SOUND 500,1: RETURN
Turn.Off: 'Turn off present selection
IF MOUSE THEN CALL MMCURSOROFF
CALL CALCATTR(FORE,BACK,ATTR)
ROW=(ULR+1+OLD): COL=ULC
DAT$=ITEMS$(SET,OLD)
CALL XQPRINTD(DAT$,ROW,COL,ATTR,0)
Turn.On: 'Turn on new selection
CALL CALCATTR(BACK,FORE,ATTR)
ROW=(ULR+1+CHOICE): COL=ULC
DAT$=ITEMS$(SET,CHOICE)
CALL XQPRINTD(DAT$,ROW,COL,ATTR,0)
IF MOUSE THEN CALL MMSETLOC(LFTCOL,8*(CHOICE+ULR)): CALL MMCURSORON
RETURN
Make.Menu: 'Place menu items in window
FOR J = 1 TO CHOICES
CALL CALCATTR(FORE,BACK,ATTR)
ROW=(ULR+1+J): COL=ULC
DAT$=ITEMS$(SET,J)
CALL XQPRINTD(DAT$,ROW,COL,ATTR,0)
NEXT J
RETURN
Quad1:
CROW=7: CCOL=20
RETURN
Quad2:
CROW=7: CCOL=60
RETURN
Quad3:
CROW=18: CCOL=60
RETURN
Quad4:
CROW=18: CCOL=20
RETURN
Getord:
ULR=VAL(LEFT$(QUADRANT$,2))+1
ULC=VAL(RIGHT$(QUADRANT$,2))
LRR=ULR+CHOICES+1
LRC=ULC+WINDLEN-1
RETURN
Puthdr:
PAD=(WINDLEN/2)-(LEN(HEADER$)/2)-.5
MID$(TEMPHDR$,PAD+1,LEN(HEADER$))=HEADER$
HEADER$=TEMPHDR$
RETURN
Done:
IF MOUSE THEN CALL MMCURSOROFF
CALL SCRREST(WHERE)
END SUB